//
//  XJBarButtonItem.swift
//  XJWeiBO
//
//  Created by 452608533 on 16/7/19.
//  Copyright © 2016年 452608533. All rights reserved.
//

import UIKit

class XJBarButtonItem: UIBarButtonItem {
    //重载构造函数
    init(title: String? = nil, imgName: String? = nil, target: AnyObject?, action: Selector) {
        super.init()
        let button = UIButton()
        
        if let tit = title{
            button.setTitle(tit, forState: UIControlState.Normal)
            button.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
            button.titleLabel?.font = UIFont.systemFontOfSize(14)
        }
        if let img = imgName {
            button.setImage(UIImage(named: img), forState: UIControlState.Normal)
        }
        button.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        button.sizeToFit()
        self.customView = button
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
